package com.dhms.vostok1.adapter

import android.annotation.SuppressLint
import android.widget.ImageView
import androidx.core.content.ContextCompat
import androidx.databinding.BindingAdapter
import androidx.recyclerview.widget.RecyclerView
import com.dhms.vostok1.data.work_bench.WorkBenchData
import com.dhms.vostok1.data.work_bench.WorkBenchItem

@BindingAdapter("workBenchItemImage")
fun bindWorkBenchItemImage(imageView: ImageView, item: WorkBenchItem) {
    item.picResId?.let { picResId ->
        imageView.apply {
            setImageDrawable(
                ContextCompat.getDrawable(
                    context,
                    picResId
                )
            )
        }
    }
}
@SuppressLint("NotifyDataSetChanged")
@BindingAdapter("workBenchListData")
fun bindWorkBenchList(recyclerView: RecyclerView, data: List<WorkBenchData>?) {
    val adapter = recyclerView.adapter as WorkBenchListAdapter
    adapter.submitList(data)
    adapter.notifyDataSetChanged()
}